<?php

namespace App\Listeners;

use App\Notifications\RegisNotifacaty;
use Illuminate\Auth\Events\Registered;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class RegisteredListener
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  Registered  $event
     * @return void
     */
    public function handle(Registered $event)
    {
//        dd($event->user);
        $user = $event->user;
        $user->email_token = str_random(10);
        $user->save();

//        下一步开始发邮件
        \Notification::send($user,new RegisNotifacaty($user));

    }
}
